<?php
class Comment_m extends MY_Model{
	
	function __construct(){
		parent::__construct();
		$this->_table = 'comment';
		$this->time_zone();
	}
	
	function get_all($module,$pid){
		$this->_table = $this->_table.' c';
		$this->db->select('c.*,u.display_name,u.avatar');
		$this->db->join('ser_users u','u.id = c.user_id');
		$this->db->where('c.pid',$pid);
		$this->db->where('c.module',$module);
		$this->db->where('c.lang',$this->_lang);
		return parent::get_all();
	}
	
	function insert($data){
		$add['lang'] = $this->_lang;
		$add['module'] = $data['module'];
		$add['content'] = $data['content'];
		$add['pid'] = $data['pid'];
		$add['full_name'] = $data['full_name'];
		$add['status'] = 1;
		$add['user_id'] = $data['user_id'];
		$add['created'] = strtotime(date('Y-m-d H:i'));
		return parent::insert($add);
	}
}